package com.cyloer.smartThread.Singleton;
public class InstanceInnerClass {
    private String str;
    private Long currentTime;

    private static class InnerClass {
        private static final InstanceInnerClass instance = new InstanceInnerClass();
    }

    public static InstanceInnerClass getInstance() {
        return InnerClass.instance;
    }

    private InstanceInnerClass() {
        initProperties();
    }

    private void initProperties() {
        this.str = "hello world!";
        this.currentTime = System.currentTimeMillis();
    }

    public void print() {
        System.out.println("time:" + currentTime + " >>> " + str );
    }

    public static void main (String[] args) {
        for (int i = 0; i < 3; i++) {
            new Thread( new Runnable() {
                @Override
                public void run() {
                    InstanceInnerClass instance = InstanceInnerClass.getInstance();
                    System.out.println("hashCode:" + instance.hashCode());
                    instance.print();
                }
            }).start();
        }
    }
}